package cn.bytecollege.controller;

import cn.bytecollege.constant.Resource;
import cn.bytecollege.entity.RoomCategory;
import cn.bytecollege.service.RoomCategoryService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "RoomCategoryFindByNameController",value = "/roomCategoryFindById")
public class RoomCategoryFindByIdController extends HttpServlet {
    String msg=null;

    private RoomCategoryService roomCategoryService=null;
    public RoomCategoryFindByIdController(){
        roomCategoryService=new RoomCategoryService();
    }


    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //接收参数
        String id=request.getParameter("id");
        Integer roomCategoryId=Integer.valueOf(id);

        //调用service方法
        RoomCategory roomCategory= roomCategoryService.findRoomCategoryByCategoryId(roomCategoryId);
//        String name = roomCategory.getRoomCategoryName();


        request.setAttribute("roomCategory",roomCategory);
        request.getRequestDispatcher(Resource.PAGE_LOCATION+"/roomCategoryUpdate.jsp").forward(request,response);
    }
}
